PDF Xpress for ActiveX - User Guide > How To > Modify PDF Document Content > Split a PDF Document into Multiple PDFs |
PDF Xpress™ supports splitting a source PDF document into multiple PDF documents using the InsertPages method.
VB Example |
Copy Code
|
---|---|
'This code demonstrates splitting a PDF into multiple PDFs On Error GoTo error Dim pdfXpress1 As New PdfXpress pdfXpress1.Initialize pdfxpress1.RaiseExceptions = True Dim document As New PdfDocument document. SetParentControl pdfXpress1 document.OpenDocument "C:\multipage.pdf","" Dim insertOpts As New InsertPagesOptions insertOpts.SourceDocument = document Dim docpageList As New PageList Dim docpageRange As New PageRange docpageList.Add docpageRange insertOpts.PageList = docpageList Dim so As New SaveOptions Dim pageCount As Integer pageCount = document.DocumentPageCount Dim a As Integer For a = 0 To pageCount - 1 insertOpts.InsertAtPageNumber = 0 docpageRange.StartPageNumber = a docpageRange.pageCount = 1 Dim doc_new As New PdfDocument doc_new.SetParentControl pdfxpress1 doc_new.NewDocument doc_new.InsertPages insertOpts so.FileName = "C:\split" + CStr(a) + ".pdf" doc_new.SaveDocument so Next a . . . GoTo finish error: MsgBox Err.Description finish: Set document = Nothing pdfxpress1.Terminate Set pdfxpress1= Nothing |